<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        div {
            padding: 30px;
            background: red;
        }
        
        ul {
            margin-top: 100px;
            height: 200px;
            width: 300px;
            overflow-y: scroll;
            background-color: #fff;
        }
        
        li {
            height: 50px;
            text-align: center;
        }
        
        li:nth-child(odd) {
            line-height: 50px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <div>
        <ul>
            <h4>eeeeeee</h4>
            <li>
                1
            </li>
            <li>
                2
            </li>
            <li>
                4
            </li>
            <li>
                6
            </li>
            <li>
                7
            </li>
            <li>
                8
            </li>
            <li>
                9
            </li>

            <li>
                4
            </li>
            <li>
                6
            </li>
            <li>
                7
            </li>
            <li>
                8
            </li>
            <li>
                9
            </li>
        </ul>
    </div>
    <button class="btn">点击</button>
    <script>
        const ul = document.querySelector('ul');
        const arr = ul.querySelectorAll('li');
        const btn = document.querySelector('.btn')
        console.log(ul.offsetTop);
        const len = arr[0].offsetTop
        console.log(len);
        console.log(arr[1].offsetTop);
        console.log(arr[5].offsetTop);
        let i = 0;
        btn.onclick = function() {
            i += 3;
            const distance = arr[i].offsetTop - len;
            ul.scrollTo({
                behavior: 'smooth',
                top: distance
            })
        }
    </script>
</body>

</html>